<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>后台管理</title>
    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.4.1-1/css/bootstrap.css}" rel="stylesheet">

    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <link th:href="@{/iconfont/iconfont.css}" rel="stylesheet">
    <style type="text/css">

        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }

        .info {
            float: left;
        }

        .pagination {
            float: right;
        }
    </style>
</head>

<body>
<!--引入抽取的topbar-->
<!--模板名：会使用thymeleaf的前后缀配置规则进行解析-->
<div th:replace="commons/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!--引入侧边栏-->
        <div th:replace="commons/bar::#sidebar(activeUri='users')"></div>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <h2><a class="btn  btn-outline-success" href="user" th:href="@{/user}">新增</a></h2>
            <div class="table-responsive">
                <table class="table table-striped table-sm table-bordered">
                    <thead>
                    <tr>
                        <th>编号</th>
                        <th>用户名</th>
                        <span>
										<th id="btnv">密码</th>
                            <!--<button class="btn-success" id="btns">显示</button>
                            <button class="btn-primary" id="btnh">隐藏</button>-->
									</span>
                        <th>邮箱</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="user:${pageInfo.list}">
                        <td>[[${user.id}]]</td>
                        <td>[[${user.username}]]</td>
                        <!--									<td type="text" class="pwd" >[[${user.password}]]</td>-->
                        <td>
                            <div th:if="${user.password}>=100000" th:text="${user.password}"></div>
                            <div th:if="${user.password}<100000" th:text="${user.password}"
                                 style="color: red"></div>
                        </td>

                        <td>[[${user.email}]]</td>
                        <td>
                            <a class="btn btn-outline-warning" th:href="@{/user/}+${user.id}">编辑</a>
                            <button th:attr="del_uri=@{/user/}+${user.id}" class="btn btn-outline-danger deleteBtn">删除
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>

                <p class="info">
                <div class="d-flex flex-row bd-highlight mb-3">
                    <div class="p-2 bd-highlight">第[[${pageInfo.pageNum}]]页</div>
                    <div class="p-2 bd-highlight">共[[${pageInfo.pages}]]页</div>
                    <div class="p-2 bd-highlight">共[[${pageInfo.total}]]条记录</div>
                </div>
                </p>
                <ul class="pagination">
                    <li class="page-item"><a class="page-link" th:href="@{/users}">首页</a></li>
                    <li class="page-item"><a class="page-link"
                                             th:href="@{/users(pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}">上一页</a>
                    </li>
                    <li class="page-item"><a class="page-link"
                                             th:href="@{/users(pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}">下一页</a>
                    </li>
                    <li class="page-item"><a class="page-link" th:href="@{/users(pageNum=${pageInfo.pages})}">尾页</a>
                    </li>
                </ul>
            </div>
        </main>
        <form id="deleteUserForm" method="post">
            <input type="hidden" name="_method" value="delete"/>
        </form>
    </div>
</div>

<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript" th:src="@{/webjars/jquery/3.5.0/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/popper.js/1.14.3/popper.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/4.4.1-1/js/bootstrap.js}"></script>

<script>
    $(".deleteBtn").click(function () {
        //删除当前
        $("#deleteUserForm").attr("action", $(this).attr("del_uri")).submit();
        return false;
    });

    /*var btns=document.getElementById("btns");
    var btnh=document.getElementById("btnh");
    var btnv=document.getElementById("btnv");

    btns.onclick=function (){
        btnv.style=""
    }

    btnh.onclick=function (){
        btnv.style.visibility="hidden"
    }*/


</script>
</body>
</html>